package com.superman.supermarket.client.activity;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.Window;
import com.google.inject.Inject;
import com.superman.mvpframe.client.ajax.PostManAsyncCallBack;
import com.superman.mvpframe.client.mvp.IPageView;
import com.superman.mvpframe.client.mvp.IPageViewPresenter;
import com.superman.mvpframe.client.utils.XJsonUtil;
import com.superman.mvpframe.client.widget.mescroll.UpAndDownCallBack;
import com.superman.supermarket.client.mvp.ShopAbstractActivity;
import com.superman.supermarket.client.view.commentlist.CommentListView;

/**
 * 评价列表页面
 * 
 * @author superman
 * @version 2018年8月15日下午5:23:44
 */
public class CommentListActivity extends ShopAbstractActivity implements UpAndDownCallBack {

	@Inject
	CommentListView commentListView;

	private String spuid;

	@Override
	public void getListDataByPage(int page) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("SPU_ID", spuid);
		map.put("TAG", 0);
		map.put("PAGE_INDEX", page);
		postman.post("/goods/comment/list", map, new PostManAsyncCallBack() {

			@Override
			public void onBusinessError(String statusCode) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onBusinessOK(String response) {
				commentListView.getPullToRefreshView().endBySize(XJsonUtil.getList(response), XJsonUtil.getCount(response));
			}
		});
	}

	@Override
	public IPageView getView() {
		return commentListView;
	}

	@Override
	public IPageViewPresenter getViewPresenter() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onActivity(EventBus eventBus) {
		// TODO Auto-generated method stub

	}

	@Override
	public void popToRefresh() {
		// TODO Auto-generated method stub

	}

	@Override
	public void popToRefresh(Object contextData) {
		// TODO Auto-generated method stub

	}

	@Override
	public void pushToRefresh() {
		spuid = Window.Location.getParameter("spuid");
		commentListView.getPullToRefreshView().initMeScroll(this, "1.2rem", "1.333333rem;");
	}

}
